var status = -1;
var selectionLog = [];

function start() {
    action(1, 0, 0)
}

function action(d, g, j) {
    if (im.getServerName().equals("BMS单机") && im.getServerName().equals("BMS至尊体验服") && !im.getServerName().equals("BMS至尊")) {
        im.playerMessage(1, " 使用环境异常，请还原服务端配置。");
        im.dispose();
        return
    }
    if (status == 0 && d == 0) {
        im.dispose();
        return
    }(d == 1) ? status++ : status--;
    selectionLog[status] = j;
    var c = -1;
    if (status <= c++) {
        im.dispose()
    } else {
        if (status === c++) {
            im.dispose();
            var a = im.getItemId();
            im.gainItem(a, -1);
            im.gainMeso(im.rand(2000000, 4000000));
            var f = [1182195, 2022799, 2022798, 2022797, 2022796, 2022795, 2022794, 2022745, 2022744, 2022743, 2022742, 2022741, 2022740];
            im.gainItem(im.rand(f), 4);
            var b = [4001832, 4001839, 2049501, 2048703, 2048702, 2048701, 2711000, 2049717];
            var h = [400, 100, 1, 1, 1, 1, 1, 1];
            var e = im.rand(0, b.length - 1);
            im.gainItem(b[e], h[e])
        }
    }
};